package com.skyolder.milkbee.service;

import com.skyolder.milkbee.domain.Moderator;
import com.skyolder.milkbee.repository.ModeratorRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;

import javax.inject.Inject;
import java.util.List;

/**
 * Service Implementation for managing Moderator.
 */
@Service
@Transactional
public class ModeratorService {

    private final Logger log = LoggerFactory.getLogger(ModeratorService.class);
    
    @Inject
    private ModeratorRepository moderatorRepository;

    /**
     * Save a moderator.
     *
     * @param moderator the entity to save
     * @return the persisted entity
     */
    public Moderator save(Moderator moderator) {
        log.debug("Request to save Moderator : {}", moderator);
        Moderator result = moderatorRepository.save(moderator);
        return result;
    }

    /**
     *  Get all the moderators.
     *  
     *  @param pageable the pagination information
     *  @return the list of entities
     */
    @Transactional(readOnly = true) 
    public Page<Moderator> findAll(Pageable pageable) {
        log.debug("Request to get all Moderators");
        Page<Moderator> result = moderatorRepository.findAll(pageable);
        return result;
    }
    @Transactional(readOnly = true) 
    public List<Moderator> findByUserId(Long userId) {
    	log.debug("Request to get all Moderators");
    	List<Moderator> result = moderatorRepository.findByUserId(userId);
    	return result;
    }

    /**
     *  Get one moderator by id.
     *
     *  @param id the id of the entity
     *  @return the entity
     */
    @Transactional(readOnly = true) 
    public Moderator findOne(Long id) {
        log.debug("Request to get Moderator : {}", id);
        Moderator moderator = moderatorRepository.findOne(id);
        return moderator;
    }

    /**
     *  Delete the  moderator by id.
     *
     *  @param id the id of the entity
     */
    public void delete(Long id) {
        log.debug("Request to delete Moderator : {}", id);
        moderatorRepository.delete(id);
    }

	public Moderator findOneByLeaguerIdAndCategoryId(Long leaguerId, Long categoryId) {
		// TODO Auto-generated method stub
		return moderatorRepository.findOneByLeaguerIdAndCategoryId(leaguerId,categoryId);
	}

	public List<Moderator> doQueryAllByCategoryId(Long cardId) {
		// TODO Auto-generated method stub
		return moderatorRepository.doQueryAllByCategoryId(cardId);
	}
}
